//
//  BaseSpread.m
//  SujetObserver
//
//  Created by Pierre DUCHENE on 05/03/10.
//  Copyright 2010 Pierre DUCHENE. All rights reserved.
//

#import "BaseSpread.h"
#import "SensorData.h"

@implementation BaseSpread

#pragma mark -
#pragma mark Memory Management
- (id) init
{
	self = [super init];
	if (self != nil) {
		sensor = nil;
		updateQueue = [[NSOperationQueue alloc] init];
	}
	return self;
}

- (void) dealloc
{
	[updateQueue release];
	updateQueue = nil;
	
	[super dealloc];
}

#pragma mark -
#pragma mark Accessors
@synthesize sensor;

#pragma mark -
#pragma mark SpreadProtocol Implementation

- (void)configureWithContext:(id<SensorProtocol,SubjectProtocol,ContextProtocol>)aSensor;
{
	sensor = aSensor;
}

- (void)execute
{
	// Update all observers
	NSSet* observers = [sensor getAllObservers];
	for (id<ObserverProtocol> o in observers) {
		[o update:sensor];
	}
}

- (SensorData*)sensorData
{
	return [sensor dataForContext];
}

@end
